package com.ljf.eslab.lab.service.impl;

import com.ljf.eslab.lab.vo.LabNameVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljf.common.utils.PageUtils;
import com.ljf.common.utils.Query;

import com.ljf.eslab.lab.dao.LabDao;
import com.ljf.eslab.lab.entity.LabEntity;
import com.ljf.eslab.lab.service.LabService;
import org.springframework.util.StringUtils;


@Service("labService")
public class LabServiceImpl extends ServiceImpl<LabDao, LabEntity> implements LabService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String) params.get("name");
        String stu = (String) params.get("stu");


        QueryWrapper<LabEntity> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)) {
            wrapper.like("name", name);
        }
        if (!StringUtils.isEmpty(Integer.valueOf(stu))) {
            wrapper.ge("capicity", stu);
        }
        IPage<LabEntity> page = this.page(
                new Query<LabEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

    @Override
    public List<LabNameVo> getLabNameList() {
        return this.baseMapper.selectLabNameList();
    }


}